﻿using System.Collections.Generic;
using Microsoft.Xna.Framework;

namespace BlockeyEssentials.ScreenSystem.ScreenTypes
{
    public abstract class PopUpScreen : Screen
    {
        #region Constructors

        /// <summary>
        /// Creates a Pop Up asking "Are you sure?". Includes answers "Yes" and "No."
        /// </summary>
        public PopUpScreen(ScreenManager oManager)
            : this(oManager, "Are you sure?", new Option("Yes", "Confirm"), new Option("No", "Cancel"))
        { }

        /// <summary>
        /// Creates a Pop Up with a custom message to let a user know about something.
        /// Only answer is "OK"
        /// </summary>
        /// <param name="oMessage">Custom Message to alert user</param>
        public PopUpScreen(ScreenManager oManager, string oMessage)
            : this(oManager, oMessage, new Option("OK", "Confirmation"))
        { }

        /// <summary>
        /// Creates a completely custom Pop Up. You pick the message and the options.
        /// </summary>
        /// <param name="oMessage">Custom Message to ask user for a choice</param>
        /// <param name="oOptions">The Choices</param>
        public PopUpScreen(ScreenManager oManager, string oMessage, params Option[] oOptions)
            : base(oManager)
        {
            Message = oMessage;

            MenuOptions = new List<Option>(oOptions.Length);
            foreach (Option s in oOptions)
            {
                MenuOptions.Add(s);
            }
        }

        #endregion

        #region Methods

        public override void Update()
        {
            if (GoToPreviousIndex())
                OptionIndex--;
            else if (GoToNextIndex())
                OptionIndex++;

            if (OptionIndex < 0)
                OptionIndex = 0;
            if (OptionIndex > MenuOptions.Count - 1)
                OptionIndex = MenuOptions.Count - 1;
        }

        public abstract bool GoToPreviousIndex();

        public abstract bool GoToNextIndex();

        #endregion

        #region Properties

        public string Message
        {
            get { return _Message; }
            set { _Message = value; }
        }

        public List<Option> MenuOptions
        {
            get { return _MenuOptions; }
            set { _MenuOptions = value; }
        }

        public int OptionIndex
        {
            get { return _OptionIndex; }
            set { _OptionIndex = value; }
        }

        #endregion

        private string          _Message;
        private List<Option>    _MenuOptions;
        private int             _OptionIndex;

    }

}
